Skip to content

Mark EntityManagerInterface::isOpen() as impure#739

Merged
ondrejmirtes merged 1 commit intophpstan:2.0.xfrom
denis-korchagin95:entitymanager-isopen-impure
Mar 13, 2026
Merged

Mark EntityManagerInterface::isOpen() as impure#739
ondrejmirtes merged 1 commit intophpstan:2.0.xfrom
denis-korchagin95:entitymanager-isopen-impure

Conversation

@denis-korchagin95
Copy link
Contributor

@denis-korchagin95 denis-korchagin95 commented Mar 13, 2026

The result of isOpen() depends on the internal state of the EntityManager
and may change during execution (for example after an exception during flush()).

This change follows the existing approach used for other Doctrine methods
that depend on mutable internal state.

Fixes #738

@denis-korchagin95 denis-korchagin95 force-pushed the entitymanager-isopen-impure branch from 86e598a to 0f140ec Compare March 13, 2026 12:59
@denis-korchagin95 denis-korchagin95 force-pushed the entitymanager-isopen-impure branch from 0f140ec to c205368 Compare March 13, 2026 13:00
@VincentLanglet VincentLanglet requested a review from staabm March 13, 2026 13:10
@staabm
Copy link
Contributor

staabm commented Mar 13, 2026

since ondrej had the impression this fix might not work, I think we should back it by a test

@ondrejmirtes
Copy link
Member

It’s fine, it will work.

@ondrejmirtes
Copy link
Member

I was confused in the original issue 😊

@ondrejmirtes
Copy link
Member

But more work is necessary here - EntityManagerInterface also has the declaration.

@VincentLanglet
Copy link
Contributor

EntityManagerInterface

This file is already updated in the PR.

There is

  • EntityManager
  • EntityManagerDecorator
  • EntityManagerInterface

@ondrejmirtes
Copy link
Member

Perfect, thank you. I was checking it out on my phone, wanted to provide as fast feedback as possible.

@ondrejmirtes ondrejmirtes merged commit 72f4f7a into phpstan:2.0.x Mar 13, 2026
50 of 51 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PHPStan assumes deterministic result for EntityManagerInterface::isOpen() within same scope

4 participants